﻿@model IEnumerable<MVCWorkflow.Models.Article>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table style="width: 100%">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Title)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Published)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.State)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Published)
        </td>
        <td>
            @if (item.State == "New")
            {
                using (Html.BeginForm("Submit", "Articles"))
                {
                    @Html.Hidden("ArticleID", item.ArticleID)
                    <input type="submit" value="Publicar" />
                }
            }
            else
            {
                @Html.ActionLink(item.State, item.State, new { workflowID = item.WorkflowID })
            }
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ArticleID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ArticleID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ArticleID })
        </td>
    </tr>
}

</table>
